Use case: SMARTCARD communication in polling mode ¶
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** Smartcard Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
SMARTCARD_HandleTypeDef hsmartcard;
HAL_SMARTCARD_Init(&hsmartcard);
HAL_SMARTCARD_Receive(&hsmartcard, aRxBuffer,
DATA_TO_RECEIVE_SIZE, 1000);
HAL_SMARTCARD_Transmit(&hsmartcard, aTxBuffer,
DATA_TO_SEND_SIZE, 1000);
|
#define DATA_TO_SEND_SIZE 256
#define DATA_TO_RECEIVE_SIZE DATA_TO_SEND_SIZE
uint8_t aTxBuffer[] = " **** Smartcard Communication **** ";
uint8_t aRxBuffer[DATA_TO_RECEIVE_SIZE];
hal_smartcard_handle_t hsmartcard;
hal_smartcard_config_t smartcard_config;
HAL_SMARTCARD_Init(&hsmartcard, HAL_SMARTCARD4);
/* add config for smartcard instance */
HAL_SMARTCARD_SetConfig(&hsmartcard, &smartcard_config);
HAL_SMARTCARD_Receive(&hsmartcard, aRxBuffer,
DATA_TO_RECEIVE_SIZE, 1000);
HAL_SMARTCARD_Transmit(&hsmartcard, aTxBuffer,
DATA_TO_SEND_SIZE, 1000);
|
Key changes ¶
The polling transmit/receive process is unchanged between HAL1 and HAL2.
HAL2 introduces the handle/config model and requires configuring the SMARTCARD instance before communication.
